package com.nulldev.util.net.experimental.groupedudp.server;

import java.net.UnknownHostException;

import com.nulldev.util.net.experimental.groupedudp.AGroupNetwork;

public class ServerGroupNetwork extends AGroupNetwork {
	/**
     * Prepares new GroupServerThread bound on interface of given hostAddress with given password and group address.
     * 
     * @param userName User's name in network
     * @param groupPassword Password required to access this group or null, if none
     * @param hostAddress Address in network interface, which should server socket use
     * @param groupAddress Address of used multi cast group
     * @param port Port of server socket
     * @param userInfoPeriod Time between server sends info about group users and requests response from other users (ms)
     * @param deadTime Time, which will server wait after sending request, before it announces user as dead (ms)
     * @throws java.net.UnknownHostException
     */
    public ServerGroupNetwork(String userName, String groupPassword, String hostAddress, 
            String groupAddress, int port, int userInfoPeriod, int deadTime) throws UnknownHostException {
            this.groupThread = new GroupServerThread(userName, groupPassword, hostAddress, 
                    groupAddress, port, userInfoPeriod, deadTime);
    }
    
        
    /**
     * Prepares new GroupServerThread bound on interface of given hostAddress with given password and default group address loaded from configuration file.
     * 
     * @param userName User's name in network
     * @param groupPassword Password required to access this group or null, if none
     * @param hostAddress Address in network interface, which should server socket use
     * @param groupAddress Address of used multi cast group
     * @param port Port of server socket
     * @throws UnknownHostException 
     */
    public ServerGroupNetwork(String userName, String groupPassword, String hostAddress, String groupAddress, int port) throws UnknownHostException{
        this(userName, groupPassword, hostAddress, groupAddress, port, 
                5000, 2000);
    }

    /**
     * Prepares new GroupServerThread on interface of given hostAddress with given password and default group address loaded from configuration file.
     * 
     * @param userName User's name in network
     * @param groupPassword Password required to access this group or null, if none
     * @param hostAddress Address in network interface, which should server socket use
     * @param port Port of server socket
     * @throws UnknownHostException 
     */
    public ServerGroupNetwork(String userName, String groupPassword, String hostAddress, int port) throws UnknownHostException{
        this(userName, groupPassword, hostAddress, "225.226.227.228", port);
    }

    /**
     * Prepares new GroupServerThread with given password and default values loaded from configuration file.
     * 
     * @param userName User's name in network
     * @param groupPassword Password required to access this group or null, if none
     * @throws UnknownHostException 
     */
    public ServerGroupNetwork(String userName, String groupPassword) throws UnknownHostException{
        this(userName, groupPassword, "0.0.0.0", 
                "225.226.227.228", 52511);
    }
    
    /**
     * Prepares new GroupServerThread with no required password and default values loaded from configuration file.
     * 
     * @param userName User's name in network
     * @throws UnknownHostException 
     */
    public ServerGroupNetwork(String userName) throws UnknownHostException{
        this(userName, null, "0.0.0.0", 
                "225.226.227.228", 52511);
    }
}
